// File name: KnightTour.java
// This file try to travel a knight all over a chees board.
// A knight start from a position and travel all unvisted positions
// until all position are visited.
// Read the problem description on page 146 of textbook.

import java.util.*;
class KnightTour
{
    public static void main(String[] args)
    {
	if (args.length != 3)
	    {
		System.out.println
		    ("Usage: java KnightTour <starting row> <starting column> 
                             <chessboard dimension>");
		System.exit(1);
	    }

	int startRow = Integer.parseInt(args[0]);
	int startCol = Integer.parseInt(args[1]);
	int dimension = Integer.parseInt(args[2]);

	KnightBoard theBoard = new KnightBoard(dimension);
	Position startPos = new Position(startRow, startCol);

	int counter = 0;
	theBoard.markAsVisited(startPos, ++counter);

	boolean result = tryToSolve(startPos, theBoard, counter);

	if (result)
	    theBoard.display();
	else
	    System.out.println("No solution found");
    }


    // This is a recursive method that performs the exhaustive search 
    // with backtracking.
    // The knight starts from the 'startPos' and try to visit all remaining available 
    // positions (no position can be visited more than once).
    // Using 'counter' to keep track of the sequence of positions which have been 
    // visited.
    public static boolean tryToSolve(Position startPos, KnightBoard theBoard, 
				                                   int counter)
    {    }
}
